package com.QK.cnstudy;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.LocalActivityManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RelativeLayout;

public class CNGroupActivity extends Activity {

    private Bundle bundle;
    private MyViewPagerWithBottom viewPager;
    private LocalActivityManager manager = null;
    private LayoutInflater mInflater;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cn_group);
        manager = new LocalActivityManager(this, true);
        manager.dispatchCreate(savedInstanceState);
        getView();
        bundle = getIntent().getExtras();
        mInflater = LayoutInflater.from(CNGroupActivity.this);
        setView();
    }

    private View getIntentView(String id, Intent intent) {
        return manager.startActivity(id, intent).getDecorView();
    }

    public void setView() {
        ArrayList<View> pageViews = new ArrayList<View>();
        Intent studyIntent = new Intent(CNGroupActivity.this, MaterialSelectActivity.class);
        Intent testIntent = new Intent(CNGroupActivity.this, TestSelectActivity.class);
        Intent statIntent = new Intent(CNGroupActivity.this, StatActivity.class);
        Intent moreIntent = new Intent(CNGroupActivity.this, MoreActivity.class);
        pageViews.add(mInflater.inflate(R.layout.first_use_00, null));
        pageViews.add(getIntentView("MaterialSelectActivity", studyIntent));
        pageViews.add(getIntentView("TestSelectActivity", testIntent));
        pageViews.add(getIntentView("StatActivity", statIntent));
        pageViews.add(getIntentView("MoreActivity", moreIntent));
        pageViews.add(mInflater.inflate(R.layout.first_use_00, null));

        List<RadioButton> radioButtons = new ArrayList<RadioButton>();
        radioButtons.add((RadioButton) findViewById(R.id.btn_study));
        radioButtons.add((RadioButton) findViewById(R.id.btn_test));
        radioButtons.add((RadioButton) findViewById(R.id.btn_stat));
        radioButtons.add((RadioButton) findViewById(R.id.btn_more));
        viewPager.setRadioButtons(radioButtons);
        viewPager.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
                        RelativeLayout.LayoutParams.FILL_PARENT));
        viewPager.setViewList(pageViews);
    }

    public void getView() {
        viewPager = (MyViewPagerWithBottom) findViewById(R.id.view_pager);
    }
}